# Recipe file for neomutt.
#
# Maintainers: (C) 2017 Mateus P. Rodrigues, mprodrigues@dragora.org.
#
# Under the terms of the GNU General Public License.

program=neomutt
version=20170714
release=1

description="
NeoMutt is a command-line mail reader (or Mail User Agent). It's a version of Mutt with added features.
"

homepage=https://www.neomutt.org/
license=GPLv2+

tarname=${program}-${version}.tar.gz

# Remote source(s)
fetch="https://github.com/neomutt/neomutt/archive/${tarname}"

# Parallel jobs for the compiler
jobs=1

# Source documentation
docs="ABOUT-NLS CODE_OF_CONDUCT.md COPYRIGHT ChangeLog.md INSTALL LICENSE.md OPS* README*"

build() {
    unpack "${tardir}/$tarname"

    cd "$srcdir"

    autoreconf -i

    ./configure \
    -enable-notmuch \
    -enable-gpgme \
    -enable-lua \
    -with-ssl \
    -with-gnutls \
    -with-sasl

    make -j${jobs}
    make -j${jobs} install DESTDIR="$destdir"

    # Compress manual pages
    if [ -d "${destdir}/$mandir" ] ; then
	(
            cd "${destdir}/$mandir"
	    find . -type f -exec lzip -9 '{}' +
	    find . -type l | while read -r file
	    do
		ln -sf "$(readlink -- "$file").lz" "${file}.lz"
		rm -- "$file"
	    done
	)
    fi

    # Copy documentation
    mkdir -p "${destdir}/usr/local/share/doc/${program}-${version}"
    cp -p $docs "${destdir}/usr/local/share/doc/${program}-${version}/"
}
